/**
 * @file        main.c
 * @author      Shadow3D (ShadowThreeD@outlook.com)
 * @brief       encrypt the data by AES.    
 * @version     0.1
 * @date        2022-01-25
 * 
 * @copyright Copyright (c) 2022
 * @note        gcc -Wall main.c ./encrypt/*.c        
 * 
 */
#include <stdio.h>
#include "./encrypt/aes.h"
#include "./encrypt/aes_crypto.h"

typedef unsigned char    uint8_t;

int main(void)
{
    uint8_t tmp_mac[6] = {0x3d, 0x3d, 0x3d, 0xc1, 0xda, 0x34};

    //uint8_t bn_tlm[] = {0x13, 0xff, 0x0d, 0x06, 0x11, 0x04, 0xf1, 0x34, 0xda, 0xc1, 0x3d, 0x3d, 0x3d, 0xbe, 0x01, 0x0b, 0x05, 0xc3, 0xe6, 0x01};

	//      0x13-ff-0d06-1104f1-34dac13d3d3d-0100ab05ece501
	uint8_t bn_tlm[] = {0x13, 0xff, 0x0d, 0x06, 0x11, 0x04, 0xf1, 0x34, 0xda, 0xc1, 0x3d, 0x3d, 0x3d, 0xb4, 0x01, 0x0b, 0x05, 0xec, 0xe6, 0x00};
	
    uint8_t encrypt_adv_data[31] = {0};

    bt_create_master_key(tmp_mac);
	
    bt_encrypt_cfb(bn_tlm, encrypt_adv_data, sizeof(bn_tlm));

    printf("befor encrypt: ");
    for(int i = 0; i < sizeof(bn_tlm); i++)
	printf("0x%02x, ", bn_tlm[i]);
    printf("\n");

    printf("after encrypt: ");
    for(int i = 0; i < sizeof(bn_tlm); i++)
	printf("0x%02x, ", encrypt_adv_data[i]);
    printf("\n");

	bt_encrypt_cfb(bn_tlm, encrypt_adv_data, sizeof(bn_tlm));

	printf("befor encrypt: ");
    for(int i = 0; i < sizeof(bn_tlm); i++)
	printf("0x%02x, ", bn_tlm[i]);
    printf("\n");

    printf("after encrypt: ");
    for(int i = 0; i < sizeof(bn_tlm); i++)
	printf("0x%02x, ", encrypt_adv_data[i]);
    printf("\n");

    return 0;
}
